import React, { Component } from 'react'
import { View, ImageBackground } from 'react-native'
import ViewShot from 'react-native-view-shot'
import Dialog, {
	DialogContent,
	SlideAnimation
} from 'react-native-popup-dialog'
import QRCode from 'react-native-qrcode-svg'

import pxToDp from '../../../libs/pxToDp'
const imageW = pxToDp(600)
const imageH = pxToDp(770)

export default class ShareCode extends Component {
	async saveImage() {
		let uri = await this.refs.shareImage.capture()
		return uri
	}
	render() {
		return (
			<ViewShot 
				style={[{ width: imageW, height: imageH, backgroundColor: 'transparent' }]}
				options={{ format: 'png', quality: 1 }}
				ref="shareImage">
				<ImageBackground
					resizeMode="stretch"
// 					source={{
// 						uri:
// 							'https://ojlty2hua.qnssl.com/image-1552698062189-5LqM57u056CB5pS25b6S5rW35oqlLmpwZw==.jpg'
// 					}}
					source={require('../../../../assets/imgs/share-code-min.jpeg')}
					style={[
						{ width: imageW, height: imageH, position: 'relative' }
					]}
				>
					{this.props.shareLink && (
						<View
							style={[
								{
									position: 'absolute',
									top: imageH * 0.61,
									left: '50%',
									marginLeft: -imageW*0.28 / 2
								}
							]}
						>
							<QRCode
								value={this.props.shareLink}
								size={imageW*0.32}
								color="#C30D23"
							/>
						</View>
					)}
				</ImageBackground>
			</ViewShot>
		)
	}
}
